<template>
	<view class="container">
		<view class="teamBox">
			<view class="team">
				<view class="num">{{is_login?userinfo.recommend_count:'--'}}</view>
				<view>我的学员</view>
			</view>
			<view class="team">
				<view class="num">{{is_login?userinfo.fans_count:'--'}}</view>
				<view>人脉圈</view>
			</view>
		</view>
		<view class="teamBox oper">
			<view class="team" @click="routerPage('/pages/user/upgrade', true)">
				<image src="@/static/image/up.png" mode="heightFix" class="img"></image>
				<view>申请升级</view>
			</view>
			<view class="team" @click="routerPage('/pages/user/authlogs', true)">
				<image src="@/static/image/auth.png" mode="heightFix" class="img"></image>
				<view>升级审核</view>
			</view>
		</view>
		<!-- <view class="listBox">
			<view class="item" @click="routerPage('/pages/user/upgrade', true)">
				<view class="tit">会员升级</view>
				<uni-icons type="right" size="22" color="#999999"></uni-icons>
			</view>
			<view class="item" @click="routerPage('/pages/user/authlogs', true)">
				<view class="tit">升级审核</view>
				<uni-icons type="right" size="22" color="#999999"></uni-icons>
			</view>
		</view> -->
	</view>
</template>

<script>
	import common from '@/static/js/common.js';
	export default {
		data() {
			return {
				userinfo: {},
				is_login: false
			}
		},
		onShow() {
			if (uni.getStorageSync('token') && uni.getStorageSync('token') != '') {
				this.is_login = true
				this.getUserMsgInfo()
			}
		},
		methods: {
			getUserMsgInfo() {
				let that = this;
				common.api({
					method: 'GET',
					url: '/mobile/user/index',
					success:(res) => {
						if (res.code != 0) {
							uni.showToast({ title: res.msg, icon: 'none' });
							return false;
						}
						that.userinfo = res.data
					}
				});
			},
			routerPage(url, isLogin) {
				if (isLogin && !this.is_login) {
					uni.showModal({
						title: '温馨提示',
						content: '请先登录',
						confirmText: '去登录',
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({url: '/pages/login/index'})
							}
						}
					});
				} else {
					uni.navigateTo({url:url})
				}
			}
		}
	}
</script>

<style scoped lang="less">
	.teamBox {
		background-color: #fff;
		padding: 20rpx 0;
		display: flex;
		align-items: center;
		.team {
			width: 50%;
			text-align: center;
			padding-bottom: 10rpx;
			&+.team {
				border-left: 2rpx solid #eee;
			}
			.num {
				height: 50rpx;
				color: red;
				font-size: 48rpx;
				margin-bottom: 20rpx;
			}
		}
		&.oper {
			margin-top: 30rpx;
			padding: 40rpx 0;
			.img {
				height: 160rpx;
				margin-bottom: 20rpx;
			}
		}
	}
</style>
